package com.wondertek.poms.dao.repo;

import com.wondertek.poms.dao.po.SpecialConfigGame;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author evan0213
 * @description
 */
@Repository
public interface ISpecialConfigGameDao extends JpaRepository<SpecialConfigGame, Long>, JpaSpecificationExecutor<SpecialConfigGame> {
	SpecialConfigGame findByKey(String key);

	SpecialConfigGame findByName(String name);

	int deleteByKey(String key);

	@Query(value = "select * from SPECIAL_CONFIG_GAME where KEY in (?1)", nativeQuery = true)
	List<SpecialConfigGame> findAllByKeys(List<String> keys);

	@Query(value = "delete from SPECIAL_CONFIG_GAME where KEY in (?1)", nativeQuery = true)
	@Modifying
	int deleteByKeys(List<String> keys);

	@Modifying
	@Query(value = "update SPECIAL_CONFIG_GAME set STATUS=?1 where KEY=?2", nativeQuery = true)
	int updateStatusByKey(Integer status, String key);

	SpecialConfigGame findByKeyAndName(String key, String name);

}
